package leetcodecompetition.D339;

import java.util.Arrays;

public class T6364 {
    public int miceAndCheese(int[] reward1, int[] reward2, int k) {

        int len = reward1.length;
        int[] diff = new int[len];
        int sum=0;
        for (int i = 0; i <len ; i++) {
            sum+=reward2[i];
            diff[i]=reward1[i]-reward2[i];
        }
        Arrays.sort(diff);
        for (int i = len-1; i>=len-k ; i--) {
            sum+=diff[i];
        }
        return sum;
    }
}
